package minipaint4Vista;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import MiniPaint4Logica.DatosDeFigura;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.util.List;
import javax.swing.JComponent;
import javax.swing.JPanel;

/**
 *
 * @author Micosil
 */
public class Linea extends JComponent{ //No tiene sentido crear una interfaz o una clase nueva - heredan de JComponent, y lo único que tienen en común es que sobreescriben el método paint de este.

    private final int X1;
    private final int Y1;
    private final int X2;
    private final int Y2;

    Linea(Point Uno, Point Dos, Rectangle bounds, List<DatosDeFigura> listaDatos) {
        X1 = (int) Uno.getX();
        Y1 = (int) Uno.getY();
        X2 = (int) Dos.getX();
        Y2 = (int) Dos.getY();
        listaDatos.add(new DatosDeFigura("Linea", Uno, Dos));
        System.out.println("X1 = " +X1+"X2="+X2+"Y1="+Y1+"Y2="+Y2);
        this.setBounds(bounds);
    }

    @Override
    public void paint(Graphics g) {
        super.paint(g);
        Graphics2D g2d = (Graphics2D)g;
        g2d.drawLine(X1, Y1, X2, Y2);
    }

}
